﻿using Mes.Domain.BoundedContext.Entities.WorkOrders;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mes.Infrastructure.Data.BoundedContext.EntityTypeConfigurations.WorkOrders
{
    public class JobStepDataEntityConfig : IEntityTypeConfiguration<JobStepData>
    {
        public void Configure(EntityTypeBuilder<JobStepData> builder)
        {
            builder.ToTable("job_step_data");
            builder.HasKey(b => new { b.Row_Id });
            builder.Property(b => b.Wo_Id).IsRequired().HasMaxLength(40);
            builder.Property(b => b.Oper_Id).IsRequired().HasMaxLength(40);
            builder.Property(b => b.Step_Grp_Id).IsRequired();
            builder.Property(b => b.Step_No).IsRequired();
            builder.Property(b => b.Lot_No).HasMaxLength(40);
            builder.Property(b => b.Sublot_No).HasMaxLength(40);
            builder.Property(b => b.State_Cd).IsRequired();
            builder.Property(b => b.Act_Start_Time_Utc);
            builder.Property(b => b.Act_Start_Time_Local);
            builder.Property(b => b.Act_Finish_Time_Utc);
            builder.Property(b => b.Act_Finish_Time_Local);
            builder.Property(b => b.Step_Data).HasMaxLength(254);
            builder.Property(b => b.Step_Data_Time_Utc);
            builder.Property(b => b.Step_Data_Time_Local);
            builder.Property(b => b.Start_User_Id).HasMaxLength(40);
            builder.Property(b => b.Finish_User_Id).HasMaxLength(40);
            builder.Property(b => b.Data_User_Id).HasMaxLength(40);
            builder.Property(b => b.Form_Done).IsRequired();
            builder.Property(b => b.Spare1).HasMaxLength(80);
            builder.Property(b => b.Spare2).HasMaxLength(80);
            builder.Property(b => b.Spare3).HasMaxLength(80);
            builder.Property(b => b.Spare4).HasMaxLength(80);
            builder.Property(b => b.Spare5).HasMaxLength(80);
            builder.Property(b => b.Spare6).HasMaxLength(80);
            builder.Property(b => b.Last_Edit_Comment).HasMaxLength(254);
            builder.Property(b => b.Last_Edit_By).HasMaxLength(40);
            builder.Property(b => b.Last_Edit_At).IsRequired();
            builder.Property(b => b.Row_Id).IsRequired().UseIdentityColumn().HasIdentityOptions(startValue: 0, incrementBy: 1, minValue: 0);
        }
    }
}
